]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Keep a minimum number of workspaces
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 16 Feb 2021 18:37:38 +0000 (19:37 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 19 Feb 2021 00:13:05 +0000 (01:13 +0100)
The scaled down workspace in the window picker looks lonely when there's
no adjacent workspace peeking in. Avoid that by always keeping a minimum
of two workspaces.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3739

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1696>

js/ui/windowManager.js

index 9d758dcd7d15e106ec025766cc90dacb51ecec51..dfc0aada00f4781dda5c6dd794dfb66d5391bde9 100644 (file)
@@ -35,6 +35,8 @@ var APP_MOTION_THRESHOLD = 30;
 
 var ONE_SECOND = 1000; // in ms
 
+var MIN_NUM_WORKSPACES = 2;
+
 const GSD_WACOM_BUS_NAME = 'org.gnome.SettingsDaemon.Wacom';
 const GSD_WACOM_OBJECT_PATH = '/org/gnome/SettingsDaemon/Wacom';
 
@@ -269,6 +271,12 @@ var WorkspaceTracker = class {
             emptyWorkspaces.push(true);
         }
 
+        // Enforce minimum number of workspaces
+        while (emptyWorkspaces.length < MIN_NUM_WORKSPACES) {
+            workspaceManager.append_new_workspace(false, global.get_current_time());
+            emptyWorkspaces.push(true);
+        }
+
         let lastIndex = emptyWorkspaces.length - 1;
         let lastEmptyIndex = emptyWorkspaces.lastIndexOf(false) + 1;
         let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
@@ -277,6 +285,8 @@ var WorkspaceTracker = class {
         // Delete empty workspaces except for the last one; do it from the end
         // to avoid index changes
         for (i = lastIndex; i >= 0; i--) {
+            if (workspaceManager.n_workspaces === MIN_NUM_WORKSPACES)
+                break;
             if (emptyWorkspaces[i] && i != lastEmptyIndex)
                 workspaceManager.remove_workspace(this._workspaces[i], global.get_current_time());
         }